
const API_BASE_URL = 'http://neteasecloudmusicapi.zhaoboy.com';

export const request = (url, method, data, loading = true) => {

    let _url = API_BASE_URL + url;

    return new Promise((resolve, reject) => {
        if(loading) {
            wx.showLoading({
                title: '加载中',
                mask: true,
            });
        }

        wx.request({
            url: _url,
            method: method,
            data: data,
            header: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },

            success(request) {
                resolve(request.data)
                wx.hideLoading();
            },

            fail(error) {
                reject(error)
            }
        })
    });
}
